import * as THREE from "../../lib/three.module";
import { STLLoader } from '../../lib/loaders/STLLoader';

const stlLoader = function () {
  const loader = new STLLoader();
  loader.load(
    this.modelPath,
    (geometry) => {
      const material = new THREE.MeshPhongMaterial({ color: 0xff5533, specular: 0x111111, shininess: 200 });
      const mesh = new THREE.Mesh(geometry, material);

      mesh.position.set(0, -0.25, 0.6);
      mesh.rotation.set(0, -Math.PI / 2, 0);
      mesh.scale.set(0.5, 0.5, 0.5);

      mesh.castShadow = true;
      mesh.receiveShadow = true;

      this.scene.add(mesh);
      this.setScaleToFitSize(mesh);
      this.setPositionToFitGrid(mesh);
      this.createPanel();
    },
    this.loadProgress.bind(this)
  );
};

export default stlLoader;
